﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Exam.Core.DBUtility;

namespace Exam.Core.DAL {
    public class QuestionOpts {

        public List<Exam.Core.Model.QuestionOpts> getOptsListByQuestionId(int id) {
            string SQL = "SELECT * FROM QuestionOpts WHERE QuestionId=" + id;
            DataTable dt = DbHelperOleDb.Query(SQL).Tables[0];
            List<Exam.Core.Model.QuestionOpts> list = new List<Exam.Core.Model.QuestionOpts>();
            foreach (DataRow dr in dt.Rows) {
                Exam.Core.Model.ExamOpts obj = new Exam.Core.Model.ExamOpts();
                obj.QuestionOptsID = dr["QuestionOptsID"].ToString().Trim();
                obj.QuestionOptsText = dr["QuestionOptsText"].ToString().Trim();
                obj.QuestionOptsValue = dr["QuestionOptsValue"].ToString().Trim();
                obj.QuestionId = id.ToString().Trim();
                list.Add(obj);
            }
            return list;
        }


        public bool DelByQid(int id) {
            string SQL2 = "DELETE FROM QuestionOpts WHERE QuestionId =" + id + "";
            bool result = false;
            try {
                DbHelperOleDb.ExecuteSql(SQL2);
                result = true;
            }
            catch (System.Exception ex) {
                result = false;
            }
            return result;
        }
    }
}
